#include "SingBlock.h"

//constructor
SingBlock::SingBlock(b2World* world, int ent_type, sf::Vector2f pos, sf::Vector2f dim, float rotation){

    buffer.loadFromFile("resources/ding.ogg");
    sound.setBuffer(buffer);

    type = ent_type;
    position = pos;
    angle = rotation;
    image = false;
    eScale = 1.0;

    if (type == BALL) radius = dim.x;
    else {
        textureRect.width = dim.x;
        textureRect.height = dim.y;
    }
    Init(world);
}

//respond to collisions
void SingBlock::collisionResponse(){

        //change color when Entity contacts another
        if (m_numContacts >0){
            rect.setFillColor(sf::Color::Yellow);
            sound.play();
        }else{
            rect.setFillColor(sf::Color::Black);
        }
}

//changes the pitch of the sound played
void SingBlock::setPitch(float pitch){
    sound.setPitch(pitch);
}
